<template>
  <div>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="旧密码">
        <el-input v-model="form.password0"></el-input>
      </el-form-item>
      <el-form-item label="新密码">
        <el-input v-model="form.password"></el-input>
      </el-form-item>
      <el-form-item label="重复新密码">
        <el-input v-model="form.password1"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即修改密码</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
name: "mima",
  data() {
    return {
      form: {
        password0: '',
        password: '',
        password1: '',
        token: window.localStorage.getItem("token")
      }
    }
  },
  methods: {
    async onSubmit() {
      console.log('submit!');
      const res = await this.$http.post('user/passwd/',this.form)
      switch (res.data.status) {
        case 200:{
          this.$message.success("更新成功")
          break
        }
        case 203:{
          this.$message.warning("重复密码需要一致")
          break
        }
        case 204:{
          this.$message.warning("旧密码错误")
          break
        }
      }
    },
  }
}
</script>

<style scoped>

</style>
